package base.service.bo.base.model.impl;

import java.util.ArrayList;
import java.util.List;
import java.util.Map;

import base.service.domain.exception.SaveException;
import common.Logger;

import base.service.bo.base.model.IBoBaseModel;
import base.service.dao.IDao;
import base.service.dao.base.model.IDaoBaseModel;
import base.service.domain.exception.DaoException;
import base.service.domain.exception.ServiceLocatorException;

/**
* @Title: BoBaseModelImpl.java
* @Package base.service.bo.base.model.impl
* @Description: TODO
* @author YeQing  
* @date 2012-6-10 下午02:15:19
* @version V1.0
 */
public class BoBaseModelImpl implements IBoBaseModel{
	
	private Logger log = Logger.getLogger(this.getClass());
	private IDaoBaseModel daoBaseModel;
	
	public BoBaseModelImpl(IDao idao) {
		this.daoBaseModel = (IDaoBaseModel) idao;
	}
	
	public List getListBaseModel(Map paramMap) throws DaoException {
		List list = new ArrayList();
		try {
			list = daoBaseModel.getListBaseModel(paramMap);
		} catch (DaoException e) {
			log.error(e.getMessage());
            throw new ServiceLocatorException(e.getMessage(), e);
		}
		return list;
	}

    public int getListBaseModelCount(Map paramMap) throws DaoException {
        int count = 0;
        try {
            /*if(count == 0) {
                throw new DaoException("asdasdasdasd");
            }*/
			count = daoBaseModel.getListBaseModelCount(paramMap);
		} catch (DaoException e) {
			log.error(e.getMessage());
            throw new ServiceLocatorException(e.getMessage(), e);
		}
		return count;
    }

    public void insertBaseModel(Map paramMap) throws SaveException {
        //int count = 0;
        try {
            /*if(count == 0) {
                throw new SaveException("Test throw DaoException.");
            }*/
            daoBaseModel.insertBaseModel(paramMap);
        } catch (DaoException e) {
            log.error(e.getMessage());
            //e.printStackTrace();
            throw new SaveException(e);
        }
    }

    public int updateBaseModel(Map paramMap) throws SaveException {
        try {
            return daoBaseModel.update(paramMap);
        } catch (DaoException e) {
            log.error(e.getMessage());
            //e.printStackTrace();
            throw new SaveException(e);
        }
    }

}
